﻿/**
 * @file system_init.c
 * @brief this is a brief description
 * @details this is the detail description.
 * @author fulong 
 * @data 9/2/2014
 * @version 1.0
 * @par Copyright (c):
 * @par First build
 *     version: fulong 
 *     data: 9/2/2014
 */
#include "system_init.h"
#include "../dev/clock.h"
#include "../dev/timer.h"
#include "../dev/interrupt.h"
#include "../dev/uart.h"
#include "../dev/key.h"
#include "../dev/485.h"
#include "../dev/display/seven_seg_led.h"
#ifdef __STM32
    #include "../bsp/arch/stm32/stm32f1xx/STM32F10x_StdPeriph_Driver/inc/stm32f10x_iwdg.h"
#endif
void system_init(void)
{
    disable_INT();
#ifdef __R8C
    MCU_Clock_Init();
#endif
    timer_init();
//  uart0_init();
#ifdef __XT14012__
#ifndef V1_4
    uart1_init();
#endif
#else
    uart1_init();
#endif
#ifndef __XT14032__
    uart2_init();
#endif
#ifdef __R8C
    timer_RA_intterrupt_init(1);
    timer_RB_intterrupt_init(1);
//  timer_RD0_intterrupt_init(c, 1);
//  U0_RX_intterrupt_init(3);
//  U0_TX_intterrupt_init(3);
//U1_TX_intterrupt_init(3);
//  U1_RX_intterrupt_init(3);
//  U2_RX_intterrupt_init(3);
//  U2_TX_intterrupt_init(3);
//  INT0_init(7);
//  INT1_init(7);
//  timer_CMPARE0_intterrupt_init(3);
#endif
#ifdef MODBUS_ENABLE
    init_485();
#endif
    enable_INT();
    key_io_init();
#ifdef MENU_ENABLE
#ifndef __SIMPLE_DISPLAY__
    hal_display_init();
#else
    seven_seg_led_init();
#endif
#endif
    wdt_init();
}
void feed_dog(void)
{
#ifdef __R8C
    disable_INT();
    wdtr = 0;
    wdtr = 0xFF;
    enable_INT();
#endif
#ifdef __STM32
    IWDG_ReloadCounter();
#endif
}
